const { ccclass, property } = cc._decorator;

import n from "./PlayerDataSys";
import l from "./SdkHelper";
import s from "./BasePageCtrl";
import c from "./UiManage";
import u from "./HelpCenterPage";

@ccclass
export default class HelpCenterPageCtrl extends s {
    @property(cc.Node)
    ui = null;

    _onCallback = false;

    onLoad() {
        super.onLoad();
        this.onUILoad();
        this._animType =AnimType.SCALE;
        this._touchControl = false;
        this._hasPeneLock = true;
        this._hasBlack = true;
        this._hasTouchLock = false;
        this._hasBlackTouch = false;
        this.addButtonListen();
    }

    start() {
        if (!this._onCallback) {
            this.ui.web.getComponent(cc.WebView).setJavascriptInterfaceScheme("hxcc");
            this.ui.web.getComponent(cc.WebView).setOnJSCallback((e, t) => {
                console.log("setOnJSCallback", t);
                switch (t.replace("hxcc://", "")) {
                    case "kefu":
                        var a = n.wx_head,
                            o = n.user_name,
                            i = n.wx_gender;
                        n.user_id;
                        l.reportData("u_click_kefu");
                        l.feedback(o, a, i);
                }
            });
            this._onCallback = true;
        }
    }

    _init(e?) {
        var t = e.url;
        this.ui.web.getComponent(cc.WebView).url = t;
    }

    onUILoad() {
        this.ui = this.node.addComponent(u);
    }

    addButtonListen() {
       UiManager.addButtonListen(this.ui.btn_close, this.clickClose, this);
    }

    clickClose() {
        this.hide();
    }
}
